package thread.threadgroup;

/**
 * 线程组
 *
 * @author lwmzzz
 * @version 1.0
 * @date 2021/5/16 19:23
 */
public class Test01 {
    public static void main(String[] args) {
        //当前main线程所在的线程组
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        System.out.println(threadGroup);
//定义线程组，如果不指定所属线程组，则自动归属于当前线程的线程组
        ThreadGroup thread_group_1 = new ThreadGroup("thread_group_1");
        System.out.println(thread_group_1);
        System.out.println(thread_group_1.getParent());

        //定义线程组
        ThreadGroup thread_group_2 = new ThreadGroup(thread_group_1, "thread_group_2");
        System.out.println(thread_group_2);

        Thread thread = new Thread(thread_group_1, "测试");
    }
}
